package com.aken.imdemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.aken.imdemo.net.CommonRequestCallbackImp
import com.aken.imdemo.net.TIMConversationManager
import com.aken.imdemo.util.startActivityNoArg
import com.orhanobut.logger.Logger
import kotlinx.android.synthetic.main.activity_login.*

class LoginActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)

        TIMConversationManager.connectTIMService(this)

        loginButton.setOnClickListener {

            val userName = userName.text.toString()
            val password = userPassword.text.toString()

            TIMConversationManager.connectLive(
                userName,
                password,
                object : CommonRequestCallbackImp {
                    override fun onSuccess() {
                        Logger.d("进入直播群成功")
                        startActivityNoArg<MainActivity>(this@LoginActivity)
                    }

                    override fun onError(errStr: String?) {
                        Logger.d("进入直播群失败$errStr")
                    }


                })
        }
    }
}
